<template>
  <a-modal
    title="新增"
    :visible="visible"
    ok-text='确定'
    @ok="handleSubmit"
    @cancel="handleCancel"
  >
    <a-form-model ref='form' :model='model' :rules='validatorRules'>
      <a-form-model-item label='考核模板名称' :labelCol='labelCol' :wrapperCol='wrapperCol' prop='templateName'>
        <a-input placeholder="请输入考核模板名称" v-model='model.templateName'></a-input>
      </a-form-model-item>
    </a-form-model>
  </a-modal>
</template>

<script>
  import {httpAction, getAction, postAction, deleteAction} from '@/api/manage'

  export default {
    name: 'createTemp',
    components: {},
    data() {
      return {
        model: {templateName: ''},
        visible: false,
        validatorRules: {
          templateName: [{required: true, message: '填写模板名!'}],
        },
        labelCol: {
          xs: {span: 24},
          sm: {span: 5}
        },
        wrapperCol: {
          xs: {span: 24},
          sm: {span: 16}
        },
        url: {
          creatTemp: '/performcheck/checkTemplateInfo/createTemplate',
        },
      }
    },
    created() {
    },
    methods: {
      add() {
        this.model = {}
        this.visible = true
      },
      handleSubmit() {
        this.$refs.form.validate((valid) => {
          if (valid) {
            httpAction(this.url.creatTemp, this.model, 'post').then((res) => {
              if (res.success) {
                this.$message.success(res.message)
                this.$emit('ok')
                this.visible = false
              } else {
                this.$message.error(res.message);
              }
            })
          }
        })
      },
      handleCancel(e) {
        this.visible = false;
      },
    }
  }
</script>

<style scoped>

</style>
